//
//  PYNotificationManager.swift
//  ltsp
//
//  Created by jyvyi_ios on 2022/6/22.
//

import Foundation

struct PYNotificationManager{
    
    static func postNotification(name:String,object:Any? = nil){
        
        NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: name), object: object)
    }

    static func addNotificationObserver(_ observer: Any, selector aSelector: Selector, name aName: String,object:Any? = nil){
        
        self.addNotificationObserver(observer, selector: aSelector, name: NSNotification.Name.init(rawValue: aName))
    }
    static func addNotificationObserver(_ observer: Any, selector aSelector: Selector, name aName: NSNotification.Name?,object:Any? = nil){
        
        NotificationCenter.default.addObserver(observer, selector: aSelector, name: aName, object: object)
    }

    static func removeNotificationObserver(_ observer: Any,name:String? = nil,object:Any? = nil){
        if name != nil{
            NotificationCenter.default.removeObserver(observer, name: NSNotification.Name.init(rawValue: name!), object: object)
        }
        else{
            NotificationCenter.default.removeObserver(observer)
        }
    }
}
